package com.byxy.computer.student.intercepter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import com.byxy.computer.student.entity.Student;

/**
 * @author Daniel
 * @E-Mail iva0512@gmail.com
 * @Date 2016年9月25日
 */
public class LoginIntercepter extends HandlerInterceptorAdapter {

	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
			throws Exception {

		Student u = (Student) request.getSession().getAttribute("student");
		String uri = request.getContextPath();
		if (u == null) {
			response.sendRedirect(uri + "/std/");
			return false;
		}
		return super.preHandle(request, response, handler);
	}
}
